package com.day12;

public class ArrayDemo {
    public static void main(String[] args) {
        int[] arr={24,69,90,57,13};
        System.out.println("排序前："+arrayToString(arr));
        for(int x=0;x<arr.length-1;x++){
            for(int i=0;i<arr.length-1-x;i++){
                if(arr[i]>arr[i+1]){
                    int temp=arr[i];
                    arr[i]=arr[i+1];
                    arr[i+1]=temp;
                }
            }
        }
        System.out.println("排序后："+arrayToString(arr));
    }

    public static String arrayToString(int[] arr){
        StringBuilder sb=new StringBuilder();
        sb.append("[");
        for(int x=0;x<arr.length;x++){
            if(x==arr.length-1){
                sb.append(arr[x]);
            }else{
                sb.append(arr[x]+",");
            }
        }
        sb.append("]");
        String s=sb.toString();
        return s;
    }
}
